<!--
 * @Author: decadent_zq 9867470+decadent-zq@user.noreply.gitee.com
 * @Date: 2023-04-05 21:10:24
 * @LastEditors: decadent_zq 9867470+decadent-zq@user.noreply.gitee.com
 * @LastEditTime: 2023-04-13 13:54:23
 * @FilePath: \absolutuniq_pc\src\views\address\Address.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<!--胡亮 2023年4月3日10:48:01-->
<!--收货地址-->
<div class="beijing">
  <el-card class="box-card" style="margin-top: 30px;">
    <el-button  type="primary" @click="addOn" style="background-color: #FFF200;color: black;border-color: transparent;">新增收货地址</el-button>
    <span style="float:right;margin-right: 63%;font-size: 14px;line-height:40px;">您已创建{{this.page.total}}个收货地址，最多可创建{{this.maximum}}个 </span>
    <!--添加窗口-->
    <div>
      <el-dialog title="添加收货地址" :visible.sync="add">
        <el-form :model="insertAddress" ref="insertAddress" :rules="rules" label-width="140px" style="text-align: left" class="demo-ruleForm">
          <el-form-item label="收货人:" style="vertical-align: middle;width: 338px" prop="addressConsignee">
            <el-input v-model="insertAddress.addressConsignee" ></el-input>
          </el-form-item>
          <el-form-item label="所在地区:" style="vertical-align: middle" prop="addressLocationProvince">
            <el-cascader size="large" :options="shAreaList" v-model="insertAddress.locationId" :props="{ children: 'shArea',value: 'id',label: 'name'}" @change="handleChange" placeholder="请选择省市区"></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址:" style="vertical-align: middle;width: 500px" prop="addressDetailed">
            <el-input v-model="insertAddress.addressDetailed" ></el-input>
          </el-form-item>
          <el-form-item label="手机号码:0086+" style="vertical-align: middle;width: 338px" prop="addressTelephoneShift">
            <el-input v-model="insertAddress.addressTelephoneShift" ></el-input>
          </el-form-item>
          <el-form-item label="固定电话:0086+" style="vertical-align: middle;width: 338px" >
            <el-input v-model="insertAddress.addressTelephoneFixed" ></el-input>
          </el-form-item>
          <el-form-item label="邮箱地址:" style="vertical-align: middle;width: 500px" >
            <el-input v-model="insertAddress.addressEmail" ></el-input>
          </el-form-item>
          <el-form-item label="地址别名:" style="vertical-align: middle;width: 338px" >
            <el-input v-model="insertAddress.addressAlias" ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="addOff">取 消</el-button>
          <el-button type="primary" @click="saveAddress">保存收货地址</el-button>
        </div>
      </el-dialog>
    </div>
    <!--修改窗口-->
    <div>
      <el-dialog title="添加收货地址" :visible.sync="update">
        <el-form :model="updateAddres" ref="updateAddres" :rules="rules" label-width="140px" style="text-align: left" class="demo-ruleForm">
          <el-form-item label="收货人:" style="vertical-align: middle;width: 338px" prop="addressConsignee">
            <el-input v-model="updateAddres.addressConsignee" ></el-input>
          </el-form-item>
          <el-form-item label="所在地区:" style="vertical-align: middle" prop="addressLocationProvince">
            <el-cascader size="large" :options="shAreaList" v-model="updateAddres.locationId" :props="{ children: 'shArea',value: 'id',label: 'name'}" @change="handleChange" placeholder="请选择省市区"></el-cascader>
          </el-form-item>
          <el-form-item label="详细地址:" style="vertical-align: middle;width: 500px" prop="addressDetailed">
            <el-input v-model="updateAddres.addressDetailed" ></el-input>
          </el-form-item>
          <el-form-item label="手机号码:0086+" style="vertical-align: middle;width: 338px" prop="addressTelephoneShift">
            <el-input v-model="updateAddres.addressTelephoneShift" ></el-input>
          </el-form-item>
          <el-form-item label="固定电话:0086+" style="vertical-align: middle;width: 338px" >
            <el-input v-model="updateAddres.addressTelephoneFixed" ></el-input>
          </el-form-item>
          <el-form-item label="邮箱地址:" style="vertical-align: middle;width: 500px" >
            <el-input v-model="updateAddres.addressEmail" ></el-input>
          </el-form-item>
          <el-form-item label="地址别名:" style="display: inline-block; vertical-align: center;width: 338px" >
            <el-input v-model="updateAddres.addressAlias" ></el-input>
          </el-form-item>
          <el-form-item label="建议填写常用名称:" style="display: inline-block; vertical-align: center;width:500px" >
            <el-button @click="updateAddres.addressAlias='家里'" style="display: inline-block; vertical-align: center">家里</el-button>
            <el-button @click="updateAddres.addressAlias='父母家'" style="display: inline-block; vertical-align: center">父母家</el-button>
            <el-button @click="updateAddres.addressAlias='公司'" style="display: inline-block; vertical-align: center">公司</el-button>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="updateOff">取 消</el-button>
          <el-button type="primary" @click="updateAddress">保存收货地址</el-button>
        </div>
      </el-dialog>
    </div>

    <el-card v-for="item in addressList" :key="item.id" class="text item"  style="margin-top: 30px;">
      <div >
        <div class="el-icon--left">
          <span style="font-size: 22px;line-height:30px;">{{item.addressAlias }}</span>
        </div>
        <div class="el-icon--left">
          <el-popover placement="bottom" width="300" trigger="click" >
            <el-input v-model="updateAddres.addressAlias" placeholder="请输入内容" style="width: 200px"></el-input>
            <el-button @click="popoverupdateAddress">保存</el-button>
            <div class="el-icon--left" style="margin-top: 5px;">
              <span>建议填写常用名称：</span>
            </div>
            <br>
            <div class="el-icon--left" style="margin-top: 5px;">
              <el-button @click="updateAddres.addressAlias='家里'" style="display: inline-block; vertical-align: center">家里</el-button>
            </div>
            <div class="el-icon--left">
              <el-button @click="updateAddres.addressAlias='父母家'" style="display: inline-block; vertical-align: center">父母家</el-button>
            </div>
            <div class="el-icon--left">
              <el-button @click="updateAddres.addressAlias='公司'" style="display: inline-block; vertical-align: center">公司</el-button>
            </div>
            <el-button slot="reference" icon="el-icon-s-tools" style="color: #534947;font-size: 15px;" type="text" @click="popoverOn(item)"></el-button>
          </el-popover>
        </div>
        <div class="el-icon--left">
          <span v-if="item.addressFlag==1"  style="font-size: 18px;line-height:30px;" class="a">默认地址</span>
        </div>
        <div class="el-pagination__rightwrapper">
          <i class="el-icon-close" @click="delAddressById(item.id)"></i>
        </div>

      <br>
        <span style="font-size: 18px;line-height:30px;">{{'收货人：' + item.addressConsignee }}</span>
      <br>
        <span style="font-size: 18px;line-height:30px;">{{'所在地区：' + item.location }}</span>
      <br>
        <span style="font-size: 18px;line-height:30px;">{{'详细地址：' + item.addressDetailed }}</span>
      <br>
        <span style="font-size: 18px;line-height:30px;">{{'手机：' + item.addressTelephoneShift }}</span>
<!--固定电话和电子邮箱（备用）-->
<!--      <br>-->
<!--        <span style="font-size: 18px;line-height:30px;">{{'固定电话：' + item.addressTelephoneFixed }}</span>-->
<!--      <br>-->
<!--        <span style="font-size: 18px;line-height:30px;">{{'电子邮箱：' + item.addressEmail }}</span>-->
        <div class="el-pagination__rightwrapper">
          <el-button type="text" style="color: #534947" @click="updateOn(item)">编辑</el-button>
        </div>
        <div class="el-pagination__rightwrapper">
          <el-button type="text" v-if="item.addressFlag!=1" style="color: #d7000f" @click="updateAddressById(item)">设为默认</el-button>
        </div>
      </div>
    </el-card>
    <div class="el-dialog-div">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="page.pageNum"
                     :page-sizes="[5, 10, 15, 20]" :page-size="page.pageSize" layout="total, prev, pager, next, jumper" :total="page.total"
                     style="float:right;margin-right: 40%;margin-top: 50px;margin-bottom:30px;"
                     v-if="page.total>5">
      </el-pagination>
    </div>

  </el-card>
</div>
</template>

<script>
import { CodeToText, regionData } from 'element-china-area-data'
export default {
  created () {
    /*收货地址列表*/
    this.getAddressByPage();
    /*全国地址*/
    this.shAreaAll();
  },
  data () {
    //手机格式验证
    var checkMobile = (rule, value, callback) => {
      const regMobile = /^1[34578]\d{9}$/;
      if (regMobile.test(value)) {
        return callback();
      }
      //返回一个错误提示
      callback(new Error("请输入合法的手机号码"));
    };
    return {
      //省市县三级联动参数
      shAreaList:{},
      //全国地址列表（用于id转name）
      shAreaNameList:{},
      //分页参数
      page: {
        // 数据总条数
        total: 0,
        // 当前页
        pageNum: 1,
        // 每页条数
        pageSize: 5
      },
      //默认地址是否设置判断条件
      flag:0,
      // 收货地址列表
      addressList: {},
      //最高地址条数(限制条件)
      maximum: 25,
      // 校验规则
      rules: {
        //收货人验证
        addressConsignee: [
          { required: true, message: '请输入收货人', trigger: 'blur' },
          { min: 1, max: 12, message: '长度在 1 到 12 个字符', trigger: 'blur' }
        ],
        //所在地区验证
        addressLocationProvince: [
          { required: true, message: '请选择所在地区(省市县)', trigger: 'change' }
        ],
        //详细地址验证
        addressDetailed: [
          { required: true, message: '请输入详细地址', trigger: 'blur' },
          { min: 5, max: 40, message: '长度在 5 到 40 个字符', trigger: 'blur' }
        ],
        addressTelephoneShift: [
          { required: true, message: "电话不能为空", trigger: "blur" },
          {validator:checkMobile,trigger: "blur"},
        ],
      },
      //选择格式
      options: regionData,
      //省市区绑定数组
      provinces: [],
      //控制添加弹窗变量
      add:false,
      //控制修改弹窗变量
      update:false,
      //收货地址添加对象
      insertAddress:{
        //收货人
        addressConsignee:"",
        //所在地区省(汉字)
        addressLocationProvince:"",
        //所在地区省(id)
        addressLocationProvinceId:"",
        //所在地区市(汉字)
        addressLocationCity:"",
        //所在地区市(id)
        addressLocationCityId:"",
        //所在地区县(汉字)
        addressLocationCounty:"",
        //所在地区县(id)
        addressLocationCountyId:"",
        //所在地区(省市县汉字)
        location:"",
        //所在地区(省市县id)
        locationId:[],
        //详细地址
        addressDetailed:"",
        //手机号
        addressTelephoneShift:"",
        //固定电话
        addressTelephoneFixed:"",
        //邮箱地址
        addressEmail:"",
        //地址别名
        addressAlias:"",
        //是否是默认(1是默认0不是默认)
        addressFlag:0,
        //用户表id(表示这条数据属于那个用户)
        userId: window.sessionStorage.getItem('userId'),
      },
      //收货地址修改对象
      updateAddres:{
        //id
        id:0,
        //收货人
        addressConsignee:"",
        //所在地区省(汉字)
        addressLocationProvince:"",
        //所在地区省(id)
        addressLocationProvinceId:"",
        //所在地区市(汉字)
        addressLocationCity:"",
        //所在地区市(id)
        addressLocationCityId:"",
        //所在地区县(汉字)
        addressLocationCounty:"",
        //所在地区县(id)
        addressLocationCountyId:"",
        //所在地区(省市县汉字)
        location:"",
        //所在地区(省市县id)
        locationId:[],
        //详细地址
        addressDetailed:"",
        //手机号
        addressTelephoneShift:"",
        //固定电话
        addressTelephoneFixed:"",
        //邮箱地址
        addressEmail:"",
        //地址别名
        addressAlias:"",
        //是否是默认(1是默认0不是默认)
        addressFlag:0,
        //用户表id(表示这条数据属于那个用户)
        userId: window.sessionStorage.getItem('userId'),
      }
    };
  },
  methods: {
    // 修改对象新增对象赋值
    handleChange(e) {
        //新增对象市级赋值(汉字)
        this.insertAddress.addressLocationProvince=this.shAreaNameList[e[0]-1].name
        //修改对象市级赋值(汉字)
        this.updateAddres.addressLocationProvince=this.shAreaNameList[e[0]-1].name
        //新增对象市级赋值(id)
        this.insertAddress.addressLocationProvinceId=e[0]
        //修改对象市级赋值(id)
        this.updateAddres.addressLocationProvinceId=e[0]
        //新增对象省级赋值(汉字)
        this.insertAddress.addressLocationCity=this.shAreaNameList[e[1]-1].name
        //修改对象省级赋值(汉字)
        this.updateAddres.addressLocationCity=this.shAreaNameList[e[1]-1].name
        //新增对象省级赋值(id)
        this.insertAddress.addressLocationCityId=e[1]
        //修改对象省级赋值(id)
        this.updateAddres.addressLocationCityId=e[1]
        //新增对象县级赋值(汉字)
        this.insertAddress.addressLocationCounty=this.shAreaNameList[e[2]-1].name
        //修改对象县级赋值(汉字)
        this.updateAddres.addressLocationCounty=this.shAreaNameList[e[2]-1].name
        //新增对象县级赋值(id)
        this.insertAddress.addressLocationCountyId=e[2]
        //修改对象县级赋值(id)
        this.updateAddres.addressLocationCountyId=e[2]
    },
    /*新增收货地址*/
    saveAddress(){
      if(this.page.total<this.maximum){
      this.$refs.insertAddress.validate((valid) => {
        if (valid) {
      this.insertAddress.userId = window.sessionStorage.getItem('userId'),
        this.$axios.post('/userAddress/saveAddress',this.insertAddress)
        .then((res) => {
          this.addOff()
          this.getAddressByPage()
        })
        } else {
          return false;
        }
      });
      }else{
        this.$message({
          type: 'warning',
          message: '地址数已达上限!'
        });
      }
    },
    /*分页查询*/
    getAddressByPage(){
      this.$axios.get('/userAddress/getAddressByPage', {
        params: {
          pageNum: this.page.pageNum,
          pageSize: this.page.pageSize,
          id:window.sessionStorage.getItem('userId')
        }
      }).then((res) => {
        this.page.total=res.data.data.totalSize
        this.addressList=res.data.data.content
        //判断有没有设置默认地址
        if(this.addressList!=null){
          for (let i=0;i<this.addressList.length;i++){
            if(this.addressList[i].addressFlag==1){
              this.flag=1
            }
          }
        }
      })
    },
    //全国地址赋值
    shAreaAll(){
      this.$axios.get('/shArea/shAreaAll')
        .then((res) => {
          this.shAreaList=res.data.data.shAreaList
          this.shAreaNameList=res.data.data.shAreaNameList
        })
    },
    /*开启添加弹窗*/
    addOn(){
      //判断是否到达最大收货地址数量
      if(this.page.total<this.maximum){
      //新增对象收货人参数初始化
      this.insertAddress.addressConsignee=""
      //新增对象在地区省(汉字)参数初始化
      this.insertAddress.addressLocationProvince=""
      //新增对象所在地区省(id)参数初始化
      this.insertAddress.addressLocationProvinceId=""
      //新增对象所在地区市(汉字)参数初始化
      this.insertAddress.addressLocationCity=""
      //新增对象所在地区市(id)参数初始化
      this.insertAddress.addressLocationCityId=""
      //新增对象所在地区县(汉字)参数初始化
      this.insertAddress.addressLocationCounty=""
      //新增对象所在地区县(id)参数初始化
      this.insertAddress.addressLocationCountyId=""
      //新增对象详细地址参数初始化
      this.insertAddress.addressDetailed=""
      //新增对象手机号参数初始化
      this.insertAddress.addressTelephoneShift=""
      //新增对象固定电话参数初始化
      this.insertAddress.addressTelephoneFixed=""
      //新增对象邮箱地址参数初始化
      this.insertAddress.addressEmail=""
      //新增对象地址别名参数初始化
      this.insertAddress.addressAlias=""
      //新增对象所在地区(省市县id)参数初始化
      this.insertAddress.locationId=[]
      //开启新增窗口
      this.add=true
      }else{
        //已达到最大上线
        this.$message({
          type: 'warning',
          message: '地址数已达上限!'
        });
      }
    },
    /*清空添加弹窗*/
    addOff(){
      //新增对象收货人参数初始化
      this.insertAddress.addressConsignee=""
      //新增对象在地区省(汉字)参数初始化
      this.insertAddress.addressLocationProvince=""
      //新增对象所在地区省(id)参数初始化
      this.insertAddress.addressLocationProvinceId=""
      //新增对象所在地区市(汉字)参数初始化
      this.insertAddress.addressLocationCity=""
      //新增对象所在地区市(id)参数初始化
      this.insertAddress.addressLocationCityId=""
      //新增对象所在地区县(汉字)参数初始化
      this.insertAddress.addressLocationCounty=""
      //新增对象所在地区县(id)参数初始化
      this.insertAddress.addressLocationCountyId=""
      //新增对象详细地址参数初始化
      this.insertAddress.addressDetailed=""
      //新增对象手机号参数初始化
      this.insertAddress.addressTelephoneShift=""
      //新增对象固定电话参数初始化
      this.insertAddress.addressTelephoneFixed=""
      //新增对象邮箱地址参数初始化
      this.insertAddress.addressEmail=""
      //新增对象地址别名参数初始化
      this.insertAddress.addressAlias=""
      //新增对象所在地区(省市县id)参数初始化
      this.insertAddress.locationId=[]
      //关闭新增窗口
      this.add=false
    },
    /*开启修改弹窗*/
    updateOn(e){
      //修改对象id参数赋值
      this.updateAddres.id=e.id
      //修改对象收货人参数赋值
      this.updateAddres.addressConsignee=e.addressConsignee
      //修改对象所在地区省(汉字)参数赋值
      this.updateAddres.addressLocationProvince=e.addressLocationProvince
      //修改对象所在地区省(id)参数赋值
      this.updateAddres.addressLocationProvinceId=e.addressLocationProvinceId
      //修改对象所在地区市(汉字)参数赋值
      this.updateAddres.addressLocationCity=e.addressLocationCity
      //修改对象所在地区市(id)参数赋值
      this.updateAddres.addressLocationCityId=e.addressLocationCityId
      //修改对象所在地区县(汉字)参数赋值
      this.updateAddres.addressLocationCounty=e.addressLocationCounty
      //修改对象所在地区县(id)参数赋值
      this.updateAddres.addressLocationCountyId=e.addressLocationCountyId
      //修改对象详细地址参数赋值
      this.updateAddres.addressDetailed=e.addressDetailed
      //修改对象手机号参数赋值
      this.updateAddres.addressTelephoneShift=e.addressTelephoneShift
      //修改对象固定电话参数赋值
      this.updateAddres.addressTelephoneFixed=e.addressTelephoneFixed
      //修改对象邮箱地址参数赋值
      this.updateAddres.addressEmail=e.addressEmail
      //修改对象地址别名参数赋值
      this.updateAddres.addressAlias=e.addressAlias
      //修改对象是否是默认(1是默认0不是默认)参数赋值
      this.updateAddres.addressFlag=e.addressFlag
      //修改对象用户表id(表示这条数据属于那个用户)参数赋值
      this.updateAddres.userId=e.userId
      //修改对象所在地区(省市县汉字)参数赋值
      this.updateAddres.location=e.location
      //修改对象所在地区(省市县id)参数赋值
      this.updateAddres.locationId=e.locationId
      //打开修改窗口
      this.update=true
    },
    /*清空修改弹窗*/
    updateOff(){
      //修改对象id参数初始化
      this.updateAddres.id=0
      //修改对象收货人参数初始化
      this.updateAddres.addressConsignee=""
      //修改对象所在地区省(汉字)参数初始化
      this.updateAddres.addressLocationProvince=""
      //修改对象所在地区省(id)参数初始化
      this.updateAddres.addressLocationProvinceId=""
      //修改对象所在地区市(汉字)参数初始化
      this.updateAddres.addressLocationCity=""
      //修改对象所在地区市(id)参数初始化
      this.updateAddres.addressLocationCityId=""
      //修改对象所在地区县(汉字)参数初始化
      this.updateAddres.addressLocationCounty=""
      //修改对象所在地区县(id)参数初始化
      this.updateAddres.addressLocationCountyId=""
      //修改对象详细地址参数初始化
      this.updateAddres.addressDetailed=""
      //修改对象手机号参数初始化
      this.updateAddres.addressTelephoneShift=""
      //修改对象固定电话参数初始化
      this.updateAddres.addressTelephoneFixed=""
      //修改对象邮箱地址参数初始化
      this.updateAddres.addressEmail=""
      //修改对象地址别名参数初始化
      this.updateAddres.addressAlias=""
      //修改对象是否是默认(1是默认0不是默认)参数初始化
      this.updateAddres.addressFlag=0
      //修改对象用户表id(表示这条数据属于那个用户)参数初始化
      this.updateAddres.userId=window.sessionStorage.getItem('userId'),
      //修改对象所在地区(省市县汉字)参数初始化
      this.updateAddres.location=""
      //修改对象所在地区(省市县id)参数初始化
      this.updateAddres.locationId=[]
      //关闭修改窗口
      this.update=false
    },
    /*popover开启*/
    popoverOn(e){
      //修改对象id参数赋值
      this.updateAddres.id=e.id
      //修改对象收货人参数赋值
      this.updateAddres.addressConsignee=e.addressConsignee
      //修改对象所在地区省(汉字)参数赋值
      this.updateAddres.addressLocationProvince=e.addressLocationProvince
      //修改对象所在地区省(id)参数赋值
      this.updateAddres.addressLocationProvinceId=e.addressLocationProvinceId
      //修改对象所在地区市(汉字)参数赋值
      this.updateAddres.addressLocationCity=e.addressLocationCity
      //修改对象所在地区市(id)参数赋值
      this.updateAddres.addressLocationCityId=e.addressLocationCityId
      //修改对象所在地区县(汉字)参数赋值
      this.updateAddres.addressLocationCounty=e.addressLocationCounty
      //修改对象所在地区县(id)参数赋值
      this.updateAddres.addressLocationCountyId=e.addressLocationCountyId
      //修改对象详细地址参数赋值
      this.updateAddres.addressDetailed=e.addressDetailed
      //修改对象手机号参数赋值
      this.updateAddres.addressTelephoneShift=e.addressTelephoneShift
      //修改对象固定电话参数赋值
      this.updateAddres.addressTelephoneFixed=e.addressTelephoneFixed
      //修改对象邮箱地址参数赋值
      this.updateAddres.addressEmail=e.addressEmail
      //修改对象地址别名参数赋值
      this.updateAddres.addressAlias=e.addressAlias
      //修改对象是否是默认(1是默认0不是默认)参数赋值
      this.updateAddres.addressFlag=e.addressFlag
      //修改对象用户表id(表示这条数据属于那个用户)参数赋值
      this.updateAddres.userId=e.userId
      //修改对象所在地区(省市县汉字)参数赋值
      this.updateAddres.location=e.location
      //修改对象所在地区(省市县id)参数赋值
      this.updateAddres.locationId=e.locationId
    },
    //分页控制方法
    handleSizeChange (val) {
      this.page.pageSize = val
      this.getAddressByPage()
    },
    //分页控制方法
    handleCurrentChange (val) {
      this.page.pageNum = val
      this.getAddressByPage()
    },
    //编辑收货地址
    updateAddress(){
      this.$refs.updateAddres.validate((valid) => {
        if (valid) {
          this.$axios.post('/userAddress/updateAddress',this.updateAddres)
            .then((res) => {
              this.updateOff()
              this.getAddressByPage()
            }) } else {
          // console.log('没通过验证');
          return false;
        }
      });
    },
    //快捷编辑地址别名
    popoverupdateAddress(){
      this.$axios.post('/userAddress/updateAddress',this.updateAddres)
            .then((res) => {
              this.getAddressByPage()
            })
    },
    //修改默认地址
    updateAddressById(e){
      this.$axios.post('/userAddress/updateAddressById',e)
        .then((res) => {
          this.getAddressByPage()
          //防止第一次添加默认地址时出现的BUG
          this.flag=1
        })
    },
    /*地址删除方法*/
    delAddressById(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.delete('/userAddress/delAddressById/'+row)
            .then((res) => {
              this.$message({
                type: 'success',
                message: '删除成功!'
              });
              this.getAddressByPage()
            })

      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },

  },
}
</script>

<style scoped>
  .beijing{
    background-color: white;
  }
  .a{
    background-color: #E6A23C;
    color: #FFFFFF
  }
  .box-card {
    width: 1110px;
    height: 1400px;
  }

</style>
